package com.example.demo.model.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.config.Constant;
import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@TableName("work_order")//指定对应的表名
public class WorkOrder {

    //指定对应的主键
    @TableId(type=IdType.AUTO)
    private Long id;//工单id 必填
    private Long orderNo;//工单编号 必填
    private Integer orderType;//工单类型 0交办 1直接答复 2无效工单 必填
    private String title;//标题 必填
    private String content;//内容 必填
    private Integer handleDeptId;//处理部门
    private Long createTime = -1L;//创建时间 必填
    private Long fenpaiTime = -1L;//分派时间
    private Boolean isOverdue;//是否超期（0否 1是）

    @TableField(exist = false)
    private String createTimeStr;//格式化后的创建时间
    @TableField(exist = false)
    private String fenpaiTimeStr;//格式化后的分派时间

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getFenpaiTime() {
        return fenpaiTime;
    }

    public void setFenpaiTime(Long fenpaiTime) {
        this.fenpaiTime = fenpaiTime;
    }

    public String getCreateTimeStr() {
        if (this.createTime != null) {
            int length = String.valueOf(this.createTime).length();
            if (length >= Constant.TIME_13) {
                return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(this.createTime));
            } else {
                return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(this.createTime * 1000));
            }
        }
        return createTimeStr;
    }
    public String getFenPaiTimeStr() {
        if (this.fenpaiTime != null) {
            int length = String.valueOf(this.fenpaiTime).length();
            if (length >= Constant.TIME_13) {
                return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(this.fenpaiTime));
            } else {
                return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(this.fenpaiTime * 1000));
            }
        }
        return fenpaiTimeStr;
    }



}
